package hpp.interviewTest;

/**
 * 将 String数组转换为数字
 * Created by hpp on 2017/8/9.
 */
public class StringToNum {

    static int stringToNumber(String s) {
        int n = 0;
        char[] cs = s.toCharArray();
        for (char c : cs) {
            n *= 10;
            n += (c - '0');
        }
        return n;
    }

    public static void main(String[] args) {

        char a = '1';
        int b = '1';
//        System.out.println(a);
//        System.out.println(b);
//        String aa = Integer.toBinaryString(8);
//        System.out.println(aa);
        System.out.println(stringToNumber("123456"));

    }

}
